package com.org.zp.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.org.zp.R;
import com.org.zp.entity.myzp.LayoutItem;

public class DeliveryListLayoutAdapter extends BaseAdapter {
	private List<LayoutItem> newsItems;
	private LayoutInflater mlinflater;

	public DeliveryListLayoutAdapter(Context context, List<LayoutItem> newsitems) {
		this.newsItems = newsitems;
		mlinflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return newsItems.size();
	}

	@Override
	public Object getItem(int position) {
		return newsItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void setChecked(int position, Boolean checked,
			boolean notifyDataSetChanged) {
		if (notifyDataSetChanged)
			this.notifyDataSetChanged();
	}

	@Override
	public View getView(final int position, View view, ViewGroup parent) {
		HrLetterHolder holder = null;
		if (null == view) {
			view = mlinflater.inflate(
					R.layout.com_delivery_list_items, null);
			view.setBackgroundResource(R.drawable.list_bg_b);
			holder = new HrLetterHolder();
			holder.name = (TextView) view
					.findViewById(R.id.com_delivery_list_name);
			holder.notice = (TextView) view
					.findViewById(R.id.com_delivery_list_notice);
			holder.date = (TextView) view
					.findViewById(R.id.com_delivery_list_date);
			holder.other = (TextView) view
					.findViewById(R.id.com_delivery_list_other);
			view.setTag(holder);
		} else {
			holder = (HrLetterHolder) view.getTag();
		}

		holder.name.setText(newsItems.get(position).getTitle());
		holder.notice.setText(newsItems.get(position).getCompany());
		holder.date.setText(newsItems.get(position).getDate());
		if("1".equals(newsItems.get(position).getOther())){
			holder.other.setText("已查看");
		}else{
			holder.other.setText("未查看");
		}
		
		
		return view;
	}

	class HrLetterHolder {
		TextView name;// 
		TextView notice;// 
		TextView date;// 
		TextView other;// 申请人数

	}

	/**
	 * 添加数据列表项
	 * 
	 * @param newsitem
	 */
	public void addNewsItem(LayoutItem newsitem) {
		newsItems.add(newsitem);
	}

}
